package com.cy.scrollviewandrecyclerview.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chuyang on 2020/7/17.
 */
public class HeaderScrollDisabledRecyclerView extends RecyclerView {
    public HeaderScrollDisabledRecyclerView(@NonNull Context context) {
        this(context,null);
    }

    public HeaderScrollDisabledRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public HeaderScrollDisabledRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false));
        HeaderRecyclerViewAdapter adapter=new HeaderRecyclerViewAdapter(getBanner(),getContext());
        setAdapter(adapter);
    }

    @Override
    public boolean onTouchEvent(MotionEvent e) {
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        return false;
    }

    private List<String> getBanner(){
        List<String> data=new ArrayList<>();
        data.add("ParentView item 0");
        data.add("ParentView item 1");
        data.add("ParentView item 2");
        data.add("ParentView item 3");
        data.add("ParentView item 4");
        data.add("ParentView item 5");
        return data;
    }
}
